<template>
	<view class="home full-height">
		<u-image class="fixed-img" mode="scaleToFill" width="100%" height="100%" :src="bg"></u-image>
		<u-image class="img" mode="scaleToFill" width="440rpx" height="70rpx" :src="`${host}/static/imgs/loading.gif`"></u-image>
	</view>
</template>

<script>
var app = getApp();
export default {
	data() {
		return {
			host:app.globalData.host,
			douyin:app.globalData.douyin,
			timer: null,
			from: '',
			bg: ''
		};
	},
	onLoad(options) {
		this.from = options.from;
	},
	onShow() {
		let url;
		let host = this.host;
		let douyin = this.douyin;
		switch (this.from) {
			case 'personInfo':
				url = '/pages/project/result/index';
				this.bg = `${host}/static/img${douyin}/6.png`;
				break;
			case 'result':
				url = '/pages/project/report/index';
				this.bg = `${host}/static/img${douyin}/8.png`;
				break;
		}
		this.timer = setTimeout(() => {
			uni.redirectTo({
				url
			});
		}, 7000);
	},
	onHide() {
		this.timer && clearTimeout(this.timer);
	},
	onShareAppMessage() {
		return {
			title: '测一测你声音的年龄',
			path: '/pages/project/home/index',
			imageUrl:'../../../static/sharelogo.jpg'
		}
	}
};
</script>

<style lang="scss" scoped>
.img {
	position: fixed;
	top: 50%;
	left: 50%;
	margin-top: 20rpx;
	margin-left: -220rpx;
	z-index: 999;
}
</style>